Skip to content

Post a null vault address for actions signed without one - #358

Open
sonirico wants to merge 1 commit into
hyperliquid-dex:masterfrom
sonirico:fix/post-null-vault-when-signed-without
Open

sonirico wants to merge 1 commit into
hyperliquid-dex:masterfrom
sonirico:fix/post-null-vault-when-signed-without

Conversation

@sonirico

@sonirico sonirico commented Dec 5, 2026

Copy link
Copy Markdown

Twenty methods sign their L1 action with no vault (sign_l1_action(..., None, ...)) but _post_action writes self.vault_address into the payload. The server hashes an L1 action with the vaultAddress of the payload, so when the Exchange was built with a vault_address it hashes something else than what was signed and recovers an address that is not the wallet.

_post_action already posts a null vault for usdClassTransfer and sendAsset. This change extends that list to the action types that are signed without a vault: setReferrer, createSubAccount, subAccountTransfer, subAccountSpotTransfer, vaultTransfer, spotDeploy, perpDeploy, CSignerAction, CValidatorAction and evmUserModify. Nothing changes for an Exchange without a vault, or for the actions that are signed for the vault.

Testnet

A freshly generated, unfunded key and Exchange(wallet, TESTNET_API_URL, vault_address=<some address>). The answer names the address the server recovered from the signature.

method master this branch
set_referrer User or API Wallet 0x<other> does not exist. User or API Wallet <wallet> does not exist.
create_sub_account 0x<other> <wallet>
sub_account_transfer 0x<other> <wallet>
sub_account_spot_transfer 0x<other> <wallet>
vault_usd_transfer 0x<other> <wallet>
use_big_blocks 0x<other> <wallet>
the 8 spot_deploy_* methods 0x<other> <wallet>
perp_deploy_register_asset, perp_deploy_set_oracle 0x<other> <wallet>
c_signer_unjail_self, the 3 c_validator_* methods Vault may not perform this action. Must deposit before performing actions. User: <wallet>

0x<other> was a different address on every call. The calls were not expected to succeed for an unfunded key: the point is which address the server recovers.

Test

test_l1_action_posts_the_vault_address_it_signs builds an Exchange with a vault, records the vault address each method passes to sign_l1_action and the vaultAddress it posts, and requires them to be equal. It covers the 20 methods above plus schedule_cancel and noop, which sign for the vault and must keep posting it. On master the 20 fail and the 2 pass.

Ran pytest tests/ (58 passed), black, isort and flake8 with the settings of .pre-commit-config.yaml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant